import server from './service';
import url from './serviceApi.config';

//接口1方法
export function getBlog(key, pageNum, pageSize) {
    return server({
        url: url.getBlog + `?key=${key}&pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'get',
        dataType: "json",
        contentType: "application/x-www-form-urlencoded;charset=UTF-8"
    })
}


// 增加访问量
export function addLook(blogId) {
    return server(
        {
            url: url.addLook + "/" + blogId + "?userIp=127.0.0.1",
            method: 'post',
            dataType: "json",
            contentType: "application/x-www-form-urlencoded;charset=UTF-8"
        }
    );
}


// 获取菜单
export function getMenu() {
    return server({
        url: url.GET_MENU,
        method: 'get',
        dataType: "json",
        contentType: "application/x-www-form-urlencoded;charset=UTF-8"
    });
}


/**
 * 获取最新的文章列表
 * @param size 获取个数
 */
export function getNewBlog(size) {
    return server({
        url: url.GET_BLOG_FRESH + "?number=" + size,
        method: 'GET',
        dataType: 'json',
        contentType: "application/json;charset=UTF-8"
    });
}


// 获取文章类型

export function getBlogById(blogId) {
    return server({
        url: `${url.GET_BLOG_CONTENT}/${blogId}`,
        method: 'GET',
        dataType: 'json',
        contentType: 'application/json;charset=UTF-8'
    });
}


